<template>
  <el-button @click="open">打开test2</el-button>
</template>

<script>
export default {
  name: "test1",
  methods:{
    open(){
      const { href } = this.$router.resolve({
        name: 'test2',
      })
      const childWindow = window.open(href,'_blank')
      window.addEventListener('message', event => {
        if (event.source === childWindow) {
          // 处理从子窗口接收到的消息
          console.log('Received message from child window:', event.data);
        }
      });
    }
  }
}
</script>

<style scoped>

</style>
